package com.zyao89.view;

import com.zyao89.view.zweb.annotations.ZCmd;
import com.zyao89.view.zweb.inter.IZWebMessageController;
import com.zyao89.view.zweb.utils.JsUtils;

/**
 * Created by zyao89 on 2017/11/15.
 * Contact me at 305161066@qq.com or zyao89@gmail.com
 * For more projects: https://github.com/zyao89
 * My Blog: https://zyao89.cn
 */
public class ParseMessage {
//    private String CMD(String data)
//    {
//        return "我是返回结果。。。";
//    }

//    private void CMD(String data)
//    {
//
//    }

    private void CMD(String data, IZWebMessageController controller) {
        System.out.println(data);
        controller.result(true, "我是返回结果1。。。");
    }

    @ZCmd("Chart1")
    private void chart_1(String data, IZWebMessageController controller) {
        System.out.println(data);
        String param = "{\"backgroundColor\":\"#2c343c\",\"visualMap\":{\"show\":false,\"min\":80,\"max\":600,\"inRange\":{\"colorLightness\":[0,1]}},\"series\":[{\"name\":\"访问来源\",\"type\":\"pie\",\"radius\":\"55%\",\"data\":[{\"value\":235,\"name\":\"视频广告\"},{\"value\":274,\"name\":\"联盟广告\"},{\"value\":310,\"name\":\"邮件营销\"},{\"value\":335,\"name\":\"直接访问\"},{\"value\":400,\"name\":\"搜索引擎\"}],\"roseType\":\"angle\",\"label\":{\"normal\":{\"textStyle\":{\"color\":\"rgba(255, 255, 255, 0.3)\"}}},\"labelLine\":{\"normal\":{\"lineStyle\":{\"color\":\"rgba(255, 255, 255, 0.3)\"}}},\"itemStyle\":{\"normal\":{\"color\":\"#c23531\",\"shadowBlur\":200,\"shadowColor\":\"rgba(0, 0, 0, 0.5)\"}}}]}";
        controller.result(true, JsUtils.json2Obj(param));
    }

    @ZCmd("Chart2")
    private void chart_2(String data, IZWebMessageController controller) {
        System.out.println(data);
        String param = "{\"title\":{\"text\":\"ECharts 入门示例\",\"left\":\"center\",\"padding\":[5,40]},\"tooltip\":{},\"xAxis\":{\"scale\":true,\"data\":[\"衬衫\",\"羊毛衫\",\"雪纺衫\",\"裤子\",\"高跟鞋\",\"袜子\"]},\"yAxis\":{},\"series\":[{\"name\":\"销量\",\"type\":\"bar\",\"data\":[5,20,36,10,10,20]}]}";
        controller.result(true, JsUtils.json2Obj(param));
    }

}
